<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const animal = {
        firstName: "chen",
        lastName: "jack",
        get fullName() {
          return `${this.lastName} ${this.firstName}`;
        },
        set fullName(value) {
          console.log(value);
          [this.lastName, this.firstName] = value.split(" ");
        },
      };
      const cat = {
        // fullName: "hahah",
        __proto__: animal,
      };

      /*
      1. 本质上不是属性设置而是方法的调用
      2. 如果想阻止只需要设置一个同名属性就可以了
      */
      // cat.setfullName("lili zhang")
      cat.fullName = "lili zhang";
      console.log("cat", cat.fullName); //lili zhang
      console.log("animal", animal.fullName);
    </script>
  </body>
</html>
